package com.srzk.youthleagueback.controller;

import com.srzk.youthleagueback.pojo.Lecture;
import com.srzk.youthleagueback.pojo.Sport;
import com.srzk.youthleagueback.pojo.ThematicEducation;
import com.srzk.youthleagueback.results.Result;
import com.srzk.youthleagueback.service.LectureService;
import com.srzk.youthleagueback.service.SportService;
import com.srzk.youthleagueback.service.ThematicEducationService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/part4")
public class SportController {

    @Autowired
    SportService service;

    @GetMapping("/sportList")
    public Result<Map<String, Object>> getList(@RequestParam("user") String user, @RequestParam("year") String year) {
        return service.getSportList(user, year);
    }

    @GetMapping("/sport")
    public Result<Map<String, Object>> get(@RequestParam("user") String user, @RequestParam("year") String year, @RequestParam("id") Long id) {
        return service.getSport(user, year, id);
    }

    @PostMapping("/sport")
    public Result<Map<String, Long>> add(Sport object, MultipartFile[] file) {
        return service.addSport(object, file);
    }

    @DeleteMapping("/sport")
    public Result<String> delete(@RequestParam("user") String user, @RequestParam("year") String year, @RequestParam("id") Long id) {
        return service.deleteSport(user, year, id);
    }

    @PostMapping("/sportUpdate")
    public Result<String> update(Sport object, MultipartFile[] files) {
        return service.updateSport(object, files);
    }
}
